import { defineStore, createPinia } from "pinia";
import { ref } from "vue";
import persist from "pinia-plugin-persistedstate"; //导入持久化插件
const pinia = createPinia();
pinia.use(persist);
// 组合式
export const useProfileStore = defineStore(
  "profile",
  () => {
    const profile = ref({});
    const setProfile = (val) => {
      profile.value = val;
    };

    return { profile, setProfile };
  },
  {
    // persist: true, // 网页端生效
    persist: {
      storage: {
        getItem(key) {
          return uni.getStorageSync(key);
        },
        setItem(key, value) {
          return uni.setStorageSync(key, value);
        },
      },
    },
  }
);
